#!/bin/bash
IP=`/sbin/ifconfig | grep 'inet addr' | grep -v 127.0.0.1 | awk '{print $2}' | awk -F ':' '{print $2}'`
echo $IP
IP_end=`echo $IP|cut -d. -f4`
echo $IP_end
HOSTNAME=app$IP_end
hostname $HOSTNAME
sed -i "/HOSTNAME/s/localhost/$HOSTNAME/" /etc/sysconfig/network
echo "127.0.0.1   localhost" > /etc/hosts
echo "$IP $HOSTNAME" >> /etc/hosts
